package lumos.util

import chisel3._
import chisel3.util._

object InstConstants {
  val ADD   = BitPat("b0000000 ????? ????? 000 ????? 01100 11")
  val ADDI  = BitPat("b??????? ????? ????? 000 ????? 00100 11")
  val ADDIW = BitPat("b??????? ????? ????? 000 ????? 00110 11")
  val ADDW  = BitPat("b0000000 ????? ????? 000 ????? 01110 11")
  val AND   = BitPat("b0000000 ????? ????? 111 ????? 01100 11")
  val ANDI  = BitPat("b??????? ????? ????? 111 ????? 00100 11")
  val AUIPC = BitPat("b??????? ????? ????? ??? ????? 00101 11")
  val BEQ   = BitPat("b??????? ????? ????? 000 ????? 11000 11")
  val BGE   = BitPat("b??????? ????? ????? 101 ????? 11000 11")
  val BGEU  = BitPat("b??????? ????? ????? 111 ????? 11000 11")
  val BLT   = BitPat("b??????? ????? ????? 100 ????? 11000 11")
  val BLTU  = BitPat("b??????? ????? ????? 110 ????? 11000 11")
  val BNE   = BitPat("b??????? ????? ????? 001 ????? 11000 11")
  val DIV   = BitPat("b0000001 ????? ????? 100 ????? 01100 11")
  val DIVU  = BitPat("b0000001 ????? ????? 101 ????? 01100 11")
  val DIVUW = BitPat("b0000001 ????? ????? 101 ????? 01110 11")
  val DIVW  = BitPat("b0000001 ????? ????? 100 ????? 01110 11")
  val JAL   = BitPat("b??????? ????? ????? ??? ????? 11011 11")
  val JALR  = BitPat("b??????? ????? ????? 000 ????? 11001 11")
  val LB    = BitPat("b??????? ????? ????? 000 ????? 00000 11")
  val LBU   = BitPat("b??????? ????? ????? 100 ????? 00000 11")
  val LD    = BitPat("b??????? ????? ????? 011 ????? 00000 11")
  val LH    = BitPat("b??????? ????? ????? 001 ????? 00000 11")
  val LHU   = BitPat("b??????? ????? ????? 101 ????? 00000 11")
  val LW    = BitPat("b??????? ????? ????? 010 ????? 00000 11")
  val LWU   = BitPat("b??????? ????? ????? 110 ????? 00000 11")
  val LUI   = BitPat("b??????? ????? ????? ??? ????? 01101 11")
  val MUL   = BitPat("b0000001 ????? ????? 000 ????? 01100 11")
  val MULW  = BitPat("b0000001 ????? ????? 000 ????? 01110 11")
  val OR    = BitPat("b0000000 ????? ????? 110 ????? 01100 11")
  val ORI   = BitPat("b??????? ????? ????? 110 ????? 00100 11")
  val REM   = BitPat("b0000001 ????? ????? 110 ????? 01100 11")
  val REMU  = BitPat("b0000001 ????? ????? 111 ????? 01100 11")
  val REMUW = BitPat("b0000001 ????? ????? 111 ????? 01110 11")
  val REMW  = BitPat("b0000001 ????? ????? 110 ????? 01110 11")
  val SB    = BitPat("b??????? ????? ????? 000 ????? 01000 11")
  val SD    = BitPat("b??????? ????? ????? 011 ????? 01000 11")
  val SH    = BitPat("b??????? ????? ????? 001 ????? 01000 11")
  val SW    = BitPat("b??????? ????? ????? 010 ????? 01000 11")
  val SLL   = BitPat("b0000000 ????? ????? 001 ????? 01100 11")
  val SLLI  = BitPat("b000000? ????? ????? 001 ????? 00100 11")
  val SLLIW = BitPat("b000000? ????? ????? 001 ????? 00110 11")
  val SLLW  = BitPat("b0000000 ????? ????? 001 ????? 01110 11")
  val SLT   = BitPat("b0000000 ????? ????? 010 ????? 01100 11")
  val SLTI  = BitPat("b??????? ????? ????? 010 ????? 00100 11")
  val SLTIU = BitPat("b??????? ????? ????? 011 ????? 00100 11")
  val SLTU  = BitPat("b0000000 ????? ????? 011 ????? 01100 11")
  val SRA   = BitPat("b0100000 ????? ????? 101 ????? 01100 11")
  val SRAI  = BitPat("b010000? ????? ????? 101 ????? 00100 11")
  val SRAIW = BitPat("b010000? ????? ????? 101 ????? 00110 11")
  val SRAW  = BitPat("b0100000 ????? ????? 101 ????? 01110 11")
  val SRL   = BitPat("b0000000 ????? ????? 101 ????? 01100 11")
  val SRLI  = BitPat("b000000? ????? ????? 101 ????? 00100 11")
  val SRLIW = BitPat("b000000? ????? ????? 101 ????? 00110 11")
  val SRLW  = BitPat("b0000000 ????? ????? 101 ????? 01110 11")
  val SUB   = BitPat("b0100000 ????? ????? 000 ????? 01100 11")
  val SUBW  = BitPat("b0100000 ????? ????? 000 ????? 01110 11")
  val XOR   = BitPat("b0000000 ????? ????? 100 ????? 01100 11")
  val XORI  = BitPat("b??????? ????? ????? 100 ????? 00100 11")
}

object ALUConstants {
  val ALUNOP   = "b00000".U
  val TRANSB   = "b00110".U
  val ALUAND   = "b00001".U
  val ALUOR    = "b00010".U
  val ALUXOR   = "b00011".U
  val ADD32    = "b00100".U
  val ADD64    = "b00101".U
  val SUBS32   = "b01000".U
  val SUBS64   = "b01001".U
  val SUBU32   = "b01010".U
  val SUBU64   = "b01011".U
  val MUL32    = "b10000".U
  val MUL64    = "b10001".U
  val DIVS32   = "b10100".U
  val DIVS64   = "b10101".U
  val DIVU32   = "b10110".U
  val DIVU64   = "b10111".U
  val REMS32   = "b11000".U
  val REMS64   = "b11001".U
  val REMU32   = "b11010".U
  val REMU64   = "b11011".U
  val SFTL32   = "b01100".U
  val SFTL64   = "b01101".U
  val SFTRS32  = "b11100".U
  val SFTRS64  = "b11101".U
  val SFTRU32  = "b11110".U
  val SFTRU64  = "b11111".U
}